<?php
require("../inc/common.inc.php");
require("checkLogin.php");
$web_title="个人资料";
$table = 'mx_app_user';
$info = $db->getinfo("select * from $table where id=$mxuserid");
?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta content="width=device-width,user-scalable=no,initial-scale=1,maximum-scale=1" name="viewport">
<title><?php echo $web_title?></title>
<meta name="searchtitle" content="<?php echo $webdb['description'];?>">
<meta name="description" content="<?php echo $webdb['description'];?>">
<meta name="keywords" content="<?php echo $webdb['metakeywords'];?>">
<meta content="application/xhtml+xml;charset=UTF-8" http-equiv="Content-Type">
<meta content="no-cache,must-revalidate" http-equiv="Cache-Control">
<meta content="no-cache" http-equiv="pragma">
<meta content="0" http-equiv="expires">
<meta content="telephone=no, address=no" name="format-detection">
<meta content="width=device-width, initial-scale=1.0" name="viewport">
<meta name="apple-mobile-web-app-capable" content="yes" /> <!-- apple devices fullscreen -->
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
<?php 
if($actions=="modifsave"){
	if(trim($nickname)==""){
		$fun->popmassage("昵称不能为空！","","popback");
		exit();
	}
	if(trim($mail)==""){
		$fun->popmassage("邮箱不能为空！","","popback");
		exit();
	}
	if(trim($address)==""){
		$fun->popmassage("地址不能为空！","","popback");
		exit();
	}
	$update_fields['nicheng'] = $nickname;
	$update_fields['mail'] = $mail;
	$update_fields['sex'] = $sex;
	$update_fields['address'] = $address;
	$db->exe_update($table, $update_fields,"id=$mxuserid");
	//更新cookie中的姓名
	$time = time()+3600*24*30;
	setcookie('nickname',$nickname,$time,'/');
	echo "<script>alert('修改成功！');location.href='/user/personal.php';</script>";
	exit();
}
$head_hide=1;require("../w_head.php")?>
</head>
<body>
<div id="ly_yifeng">个人资料</div>

<div class="list_ban"><img src="/images/p2.jpg" />
  <div class="list_bana">
<!--    <div class="list_bana_l"><img src="/images/31.jpg" /><div class="list_bana_la">   &nbsp;</div></div> -->
   <div class="list_bana_r">
    <dl class="list_bana_ra"><dt><?php echo $info['realname'];?>，欢迎您!</dt><!-- <dt>会员等级:<b style="color:#f30;">&nbsp;A类会员</b></dt> --></dl> 
	<dl class="list_bana_rb"><dt>余额：￥<?php echo $info['money']?></dt></dl> 
	<dl class="list_bana_rb"><dt>积分：<?php echo $info['integral']?></dt></dl>
   </div>
  </div>
 </div>
 
 <!--dan-->
<div class="member_2">
<?php if($actions=='modif'){?>
	<div id="hyzl">
	<h1>
    	<div class="l"><img src="/images/user_36.png" /></div>
        <div class="c">个人资料</div>
    </h1>
    <form id="form1" name="form1" method="post" action="personal.php?actions=modifsave">
    <ul>
      <table width="90%" height="178" border="0" align="center" cellpadding="10" cellspacing="0">
        <tr>
        <td class="width40">姓名</td>
          <td><?php echo $info['realname']?>&nbsp;&nbsp;(<font color="red">不可更改</font>)</td>
        </tr>
          <td class="width40">手机</td>
          <td><?php echo $info['mobile']?>&nbsp;&nbsp;(<font color="red">不可更改</font>)</td>
        </tr>
         <tr>
          <td class="width40">性别</td>
          <td><label for="select"></label>
            <select name="sex" id="sex" styel="font-size:1.5em">
              <option <?php if($info['sex'] == 0){echo 'selected';}?> value="0">保密</option>
              <option <?php if($info['sex'] == 1){echo 'selected';}?> value="1">男</option>
              <option <?php if($info['sex'] == 2){echo 'selected';}?> value="2">女</option>
          </select></td>
        </tr>
        <tr>
          <td class="width40">QQ</td>
          <td><input type="text" name="qq" value="<?php echo $info['qq']?>" id="qq" class="input1" /></td>
        </tr>
        <tr>
          <td class="width40">邮箱</td>
          <td><input type="text" name="mail" value="<?php echo $info['mail']?>" id="mail" class="input1" /></td>
        </tr>
        <tr>
          <td class="width40">地址</td>
          <td><input type="text" name="address" value="<?php echo $info['address']?>" id="address" class="input1" /></td>
        </tr>
      </table>
      <div class="input2"><a href="javascript:void(0);" onclick="check_from();">确认修改</a></div>
    </ul>
  </form>
</div>
<script>
	function check_from(){
// 		var nickname = $('#nickname').val();
// 		if(nickname==""){
// 			alert("昵称不能为空！")
// 			return false;
// 		}
// 		var mail = $("#mail").val();
// 		if(mail==""){
// 			alert("邮箱不能为空！");
// 			return false;
// 		}
// 		var address = $("#address").val();
// 		if(address==""){
// 			alert("地址不能为空！");
// 			return false;
// 		}
		$("#form1").submit();
	}
</script>
<?php }else{?>
	<div id="hyzl">
	<h1>
    	<div class="l"><img src="/images/user_36.png" /></div>
        <div class="c">个人资料</div>
       <div class="r"><a href="personal.php?actions=modif">修改</a></div>
    </h1>
    <ul>

    	<li>姓名：<?php echo $info['realname']?></li>
        <li>手机：<?php echo $info['mobile']?></li>
        <li>性别：<?php if($info['sex']==1){echo '男';}elseif($info['sex']==2){echo '女';}else{echo '保密';}?></li>
    	<li>QQ：<?php echo $info['qq']?></li>
        <li>邮箱：<?php echo $info['mail']?></li>
        <li>地址：<?php echo $info['address']?></li>
    </ul>
</div>
<?php }?>
</div>
 <!--dan-->
<div class="clear"></div>
<?php require("../w_foot.php")?>